package com.xiaocg.momento.write_box;

public class GameRole {
    private int vit;//生命力
    private int atk;//攻击力
    private int def;//防御力

    public void initState(){
        this.vit = 100;
        this.atk = 100;
        this.def = 100;
    }

    public void fight(){
        this.vit = 0;
        this.atk = 0;
        this.def = 0;
    }

    /**
     * 保存角色状态
     * @return
     */
    public GameRoleMomento save(){
        return new GameRoleMomento(vit,atk,def);
    }

    /**
     * 恢复角色状态
     * @return
     */
    public void recoverState(GameRoleMomento momento){
        this.vit = momento.getVit();
        this.atk = momento.getAtk();
        this.def = momento.getDef();
    }

    /**
     * 恢复角色状态
     * @return
     */
    public void show(){
        System.out.println("生命力 "+this.vit);
        System.out.println("攻击力 "+this.atk);
        System.out.println("防御力 "+this.def);
    }

    public int getVit() {
        return vit;
    }

    public void setVit(int vit) {
        this.vit = vit;
    }

    public int getAtk() {
        return atk;
    }

    public void setAtk(int atk) {
        this.atk = atk;
    }

    public int getDef() {
        return def;
    }

    public void setDef(int def) {
        this.def = def;
    }
}
